package com.motorwaymanage.actions;

import java.util.List;

import com.motorwaymanage.beans.CheckInfo;
import com.motorwaymanage.beans.JsonObject;
import com.motorwaymanage.biz.ICheckInfoBiz;
import com.motorwaymanage.impl.CheckInfoBizImpl;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class CheckInfoAction extends ActionSupport implements ModelDriven<CheckInfo>{

	private static final long serialVersionUID = 1L;
	private CheckInfo ci=new CheckInfo();
	private ICheckInfoBiz checkInfoBiz=new CheckInfoBizImpl();
	private JsonObject json;
	public String selectCheckInfo(){
		List<CheckInfo> list=checkInfoBiz.selectCheckInfo();
		if(list!=null){
			json=new JsonObject();
			json.setRows(list);
			return SUCCESS;
		}
		return null;
	}
	
	public String addCheckInfo(){
		System.out.println(ci);
		int result=checkInfoBiz.addCheckInfo(ci);
		json=new JsonObject();
		json.setObj(result);
		return SUCCESS;
	}
	
	public String delCheckInfo(){
		int result=checkInfoBiz.delCheckInfo(ci.getCid());
		json=new JsonObject();
		json.setObj(result);
		return SUCCESS;
	}
	
	public JsonObject getJson() {
		return json;
	}

	@Override
	public CheckInfo getModel() {
		if (null == ci) {
			   return ci = new CheckInfo();
			  }
			  return ci;
	}
}
